]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
userMenu: Use LoginManager for suspend
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 19 Oct 2012 15:41:10 +0000 (17:41 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 23 Oct 2012 19:14:10 +0000 (21:14 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=686482

js/ui/userMenu.js

index 8ebfef3ad92490188ef7f99d7713f29e48037ba5..fdc9bad7bf2c648c795149b1294740b0765d394e 100644 (file)
@@ -9,11 +9,11 @@ const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Tp = imports.gi.TelepathyGLib;
-const UPowerGlib = imports.gi.UPowerGlib;
 const Atk = imports.gi.Atk;
 
 const BoxPointer = imports.ui.boxpointer;
 const GnomeSession = imports.misc.gnomeSession;
+const LoginManager = imports.misc.loginManager;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
@@ -482,10 +482,11 @@ const UserMenuButton = new Lang.Class({
         this._presence = new GnomeSession.Presence();
         this._session = new GnomeSession.SessionManager();
         this._haveShutdown = true;
+        this._haveSuspend = true;
 
         this._accountMgr = Tp.AccountManager.dup();
 
-        this._upClient = new UPowerGlib.Client();
+        this._loginManager = LoginManager.getLoginManager();
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
         this._iconBox = new St.Bin();
@@ -565,14 +566,15 @@ const UserMenuButton = new Lang.Class({
         // the lockdown setting changes, which should be close enough.
         this.menu.connect('open-state-changed', Lang.bind(this,
             function(menu, open) {
-                if (open)
-                    this._updateHaveShutdown();
+                if (!open)
+                    return;
+
+                this._updateHaveShutdown();
+                this._updateHaveSuspend();
             }));
         this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
                                        Lang.bind(this, this._updateHaveShutdown));
 
-        this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
-
         Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
         this._sessionUpdated();
     },
@@ -641,9 +643,15 @@ const UserMenuButton = new Lang.Class({
             }));
     },
 
-    _updateSuspendOrPowerOff: function() {
-        this._haveSuspend = this._upClient.get_can_suspend();
+    _updateHaveSuspend: function() {
+        this._loginManager.canSuspend(Lang.bind(this,
+            function(result) {
+                this._haveSuspend = result;
+                this._updateSuspendOrPowerOff();
+        }));
+    },
 
+    _updateSuspendOrPowerOff: function() {
         if (!this._suspendOrPowerOffItem)
             return;
 
@@ -846,13 +854,13 @@ const UserMenuButton = new Lang.Class({
                 let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
                     Main.screenShield.disconnect(tmpId);
 
-                    this._upClient.suspend_sync(null);
+                    this._loginManager.suspend();
                 }));
 
                 this.menu.close(BoxPointer.PopupAnimation.NONE);
                 Main.screenShield.lock(true);
             } else {
-                this._upClient.suspend_sync(null);
+                this._loginManager.suspend();
             }
         }
     }